package org.mspring.platform.api.rss.elements;

import electric.xml.Element;
import electric.xml.Elements;

import java.util.ArrayList;
import java.util.List;

/**
 * 
 * @author Gao Youbo
 * @since 2013年7月26日
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
public class CategorizedElement extends SyndicatedElement {
    private static final long serialVersionUID = 3765400025372559575L;
    List categories;

    public List getCategories() {
        return this.categories;
    }

    void setCategories(List paramList) {
        this.categories = paramList;
    }

    public Category addCategory(String paramString1, String paramString2) {
        if (this.categories == null)
            this.categories = new ArrayList();
        Category localCategory = new Category();
        localCategory.setText(paramString1);
        localCategory.setDomain(paramString2);
        this.categories.add(localCategory);
        return localCategory;
    }

    public Category addCategory(String paramString) {
        return addCategory(paramString, null);
    }

    protected static void setCategories(Element paramElement, CategorizedElement paramCategorizedElement) {
        Elements localElements = paramElement.getElements("category");
        while (localElements.hasMoreElements()) {
            Element localElement = localElements.next();
            String str1 = localElement.getString();
            String str2 = localElement.getAttributeValue("domain");
            paramCategorizedElement.addCategory(str1, str2);
        }
    }
}